import 'package:flutter/material.dart';

class CustomListView extends ListView {
  CustomListView.builder({
    required int itemCount,
    required IndexedWidgetBuilder itemBuilder,
  }) : super.builder(
          //自动计算ListView内容高度
          shrinkWrap: true,
          //禁止滚动
          physics: NeverScrollableScrollPhysics(),
          padding: EdgeInsets.zero,
          itemCount: itemCount,
          itemBuilder: itemBuilder,
        );

  CustomListView.separated({
    required IndexedWidgetBuilder itemBuilder,
    required int itemCount,
  }) : super.separated(
          padding: EdgeInsets.zero,
          //自动计算ListView内容高度
          shrinkWrap: true,
          //禁止滚动
          physics: NeverScrollableScrollPhysics(),
          separatorBuilder: (ctx, index) => Divider(),
          itemCount: itemCount,
          itemBuilder: itemBuilder,
        );
}
